from wsgiref.simple_server import make_server
from med.web import get_app


def get_domain_default():
    return "localhost"


def get_port_default():
    return 6543


def get_server(domain, port, enable_cors):
    return make_server(domain, port, get_app(enable_cors))


def run_test_server(domain=get_domain_default(), port=get_port_default()):
    server = get_server(domain, port, True)
    print(f"Starting server on: http://{domain}:{port}/")
    server.serve_forever()
